package FlowGraph.Nodes;

import antlr.collections.AST;
import antlr.*;

import JavaGrammar.TreeScanners.ParDefParser;
import util.Line;
import FlowGraph.FlowGraphNode;
import FlowGraph.StatementInfo.StatementInfo;

//////////////////////////////////////////////////////////////////////////
//// CatchBeginNode
/**

@author Ivan Jeukens
@version v 0.1 21/02/2002
*/
public class CatchBeginNode extends FlowGraphNode {

    public CatchBeginNode(AST node) {
        super(node, CATCH_BEGIN, 1, 1);

        _parameterAST = node.getFirstChild();
        _parser = new ParDefParser();
        try {
            _parser.parameterDef(_parameterAST);
        }
        catch(RecognitionException ex) {
            System.out.println("RecognitionException:");
            System.out.println(ex);
        }
        _statementInfo = new StatementInfo(this, _parameterAST);
    }

    ///////////////////////////////////////////////////////////////////
    ////                        public methods                     ////
    
    public AST getParameterAST() {
        return _parameterAST;
    }
    
    public String toString() {
        return new String("catch()");
    }

    public String getParameterDef() {
        return _parser.getCurrentPar();
    }
    
    public void setCatchEnd(CatchEndNode node) {
        _catchEnd = node;
    }

    public CatchEndNode getCatchEnd() {
        return _catchEnd;
    }

    public String getTypeName() {
        return _parser.getTypeName();
    }

    public void setBegLine(Line l) {
        _begLine = l;
    }

    public Line getBegLine() {
        return _begLine;
    }

    public void setEndLine(Line l) {
        _endLine = l;
    }

    public Line getEndLine() {
        return _endLine;
    }

    public StatementInfo getStatementInfo() {
        return _statementInfo;
    }
    
    ///////////////////////////////////////////////////////////////////
    ////                      private variables                    ////

    private AST _parameterAST;
    private ParDefParser _parser;
    private CatchEndNode _catchEnd;

    private Line _endLine;
    private Line _begLine;

    private StatementInfo _statementInfo;
}
